package com.shengzai.hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.Bytes;

import java.io.IOException;
import java.util.List;

public class CellGetData {
    public static void main(String[] args) throws IOException {
        Configuration conf = new Configuration();
        conf.set("hbase.zookeeper.quorum","master,node1,node2");

        Connection connection = ConnectionFactory.createConnection(conf);

        TableName tableName = TableName.valueOf("api_test:api_student");

        Table table = connection.getTable(tableName);

        Get get = new Get("1810404125".getBytes());

        Result result = table.get(get);

        List<Cell> cells = result.listCells();

        for (Cell cell : cells) {
            String family = Bytes.toString(CellUtil.cloneFamily(cell));
            String rows = Bytes.toString(CellUtil.cloneRow(cell));
            String value = Bytes.toString(CellUtil.cloneValue(cell));
            System.out.println(family+rows+value);
        }


    }
}
